#include<iostream>
#include<cstring>
using namespace std;

const int C = 5 * 7 * 8 * 9;
int rn[C][9];
int maxrn[9], cnt[9];
int l, r;
int ans = 0;

void Pre(){
	memset(rn, 0, sizeof(rn));
	memset(maxrn, 0, sizeof(maxrn));
	for(int num = 0; num < C; num++){
		for(int i = 2; i < 10; i++){
			int rni = num % i;
			rn[num][rni]++;
			maxrn[rni] = max(maxrn[rni], rn[num][rni]); 
		}
	}
}

bool IsGood(int num){
    int id = num % C;
	 
	for(int i = 0; i < 9; i++){
        if(cnt[i] > rn[id][i]){
            return false;
 		}
	}
	return true;
}

void DFS(int num){
	if(num >= l && num <= r && IsGood(num)){
		ans++;
	}
	
	if(num * 10 > r){
		return;
	}
	
	for(int i = 0; i < 9; i++){
		if(cnt[i] < maxrn[i]){
			cnt[i]++;
			DFS(num * 10 + i);
			cnt[i]--;
		}
		else{
			break;
		}
	}
}

int main(){
	cin >> l >> r;
	
	r = min(r, 87654321);
	Pre(); 
	memset(cnt, 0, sizeof(cnt));
	for(int num = 1; num < 9; num++){
		cnt[num] = 1;
		DFS(num);
		cnt[num] = 0;
	}	
	cout << ans << endl;
	return 0;
}
